﻿@model RoadFlow.Model.ProgramField
<form id="form1" method="post">
    @Html.AntiForgeryToken()
    <div>
        <input type="hidden" name="Id" value="@Model.Id" />
        <input type="hidden" name="ProgramId" value="@Model.ProgramId" />
        <table cellpadding="0" cellspacing="1" border="0" width="95%" class="formtable" style="margin-top:10px;">
            <tr>
                <th style="width: 80px;">字段：</th>
                <td>
                    <select class="myselect2" style="width:350px;" maxheight="500" name="Field" id="Field">
                        <option value=""></option>
                        @Html.Raw(ViewData["fieldOptions"])
                    </select>
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">显示标题：</th>
                <td><textarea class="mytextarea" style="width:80%;height:60px;" name="ShowTitle" id="ShowTitle">@Model.ShowTitle</textarea></td>
            </tr>
            <tr>
                <th style="width: 80px;">显示类型：</th>
                <td>
                    <select id="ShowType" name="ShowType" class="myselect" onchange="showCustomTR(this.value);">
                        @Html.Raw(ViewData["showTypeOptions"])
                    </select>
                    <span id="showformatspan" style="margin-left:10px; display:none;">格式：<input type="text" class="mytext" value="@Model.ShowFormat" id="ShowFormat" name="ShowFormat" style="width:200px" /></span>
                </td>
            </tr>
            <tr id="customtr" style="display:none;">
                <th style="width: 80px;">自定义值：</th>
                <td><textarea class="mytextarea" style="width:99%;height:60px;" id="CustomString" name="CustomString">@Model.CustomString</textarea></td>
            </tr>
            <tr>
                <th style="width: 80px;">对齐方式：</th>
                <td>
                    <select class="myselect" id="Align" name="Align">
                        @Html.Raw(ViewData["alignOptions"])
                    </select>
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">列表宽度：</th>
                <td>
                    <input type="text" class="mytext" name="Width" validate="canempty,int" id="Width" value="@Model.Width" />
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">是否排序：</th>
                <td>
                    <input type="radio" value="1" name="IsSort" @(1 == Model.IsSort ? "checked ='checked'" : "") id="IsSort_1" style="vertical-align:middle" /><label style="vertical-align:middle" for="IsSort_1">是</label>
                    <input type="radio" value="0" name="IsSort" @(0 == Model.IsSort ? "checked ='checked'" : "") id="IsSort_0" style="vertical-align:middle" /><label style="vertical-align:middle" for="IsSort_0">否</label>
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">默认排序：</th>
                <td>
                    <input type="radio" value="1" name="IsDefaultSort" @(1 == Model.IsDefaultSort ? "checked ='checked'" : "") id="IsDefaultSort_1" style="vertical-align:middle" /><label style="vertical-align:middle" for="IsDefaultSort_1">是</label>
                    <input type="radio" value="0" name="IsDefaultSort" @(0 == Model.IsDefaultSort ? "checked ='checked'" : "") id="IsDefaultSort_0" style="vertical-align:middle" /><label style="vertical-align:middle" for="IsDefaultSort_0">否</label>
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">显示顺序：</th>
                <td>
                    <input type="text" class="mytext" name="sort" id="sort" value="@Model.Sort" />
                </td>
            </tr>
        </table>
    </div>
    <div class="buttondiv">
        <input type="button" value=" 保 存 " class="mybutton" onclick="save(this);" />
        <input type="button" class="mybutton" onclick="window.location = 'Set_ListField@(Html.Raw(ViewData["queryString"]))';" value=" 返 回 " />
    </div>
</form>
<script type="text/javascript">
    $(function() {
        showCustomTR($("#ShowType").val());
    });
    function showCustomTR(v) {
        if ("6" == v) {
            $("#customtr").show();
        }
        else {
            $("#customtr").hide();
        }
        if ("2" == v || "3" == v) {
            $("#showformatspan").show();
        }
        else {
            $("#showformatspan").hide();
        }
    }
    function save(but) {
        var f = document.forms[0];
        if (new RoadUI.Validate().validateForm(f)) {
            var o = RoadUI.Core.serializeForm($(f));
            $(but).prop("disabled", true);
            $.ajax({
                url: "SaveSet_ListField@(Html.Raw(ViewData["queryString"]))", data: o, type: "post", success: function (text) {
                    alert(text);
                    $(but).prop("disabled", false);
                    if (text.indexOf('成功!') >= 0) {
                        window.location = "Set_ListField@(Html.Raw(ViewData["queryString"]))";
                    }
                }
            });
        }
    }
</script>